package com.ysq.www.api.user.controller;


import com.ysq.www.api.user.service.ICollectService;
import com.ysq.www.common.annotation.AuthToken;
import com.ysq.www.common.result.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 收藏记录表 前端控制器
 * </p>
 *
 * @author dql
 * @since 2020-08-18
 */
@RestController
@RequestMapping("/user/collect")
public class CollectController {

    @Autowired
    private ICollectService collectService;

    /**
     * 收藏/取消收藏
     * @param userId 用户id
     * @param contentId 内容id
     * @param type 收藏类型：1资讯，2活动
     * @param isCollect 0取消收藏，1收藏
     * @return ResultMsg
     */
    @GetMapping("/addOrUpdate")
    @AuthToken
    public ResultMsg addOrUpdateById(@RequestParam(required = true) Integer userId,
                                     @RequestParam(required = true) Integer contentId,
                                     @RequestParam(required = true) Integer type,
                                     @RequestParam(required = true) Integer isCollect){
        ResultMsg rm = collectService.addOrUpdateById(userId,contentId,type,isCollect);
        return rm;
    }


}
